//
//  NGTipView.m
//  AHSCB
//
//  Created by PT_staff on 11-10-9.
//  Copyright 2011年 __MyCompanyName__. All rights reserved.
//

#import "SZNGTipView.h"

@implementation SZWaitView

- (id)initWithString:(NSString*)str
{
    self = [super init];
    if (self) {
        // Initialization code
        self.frame = CGRectMake(0, 0, newwidth, newheight);
        
        
//        // 设置普通状态的动画图片
        
        NSMutableArray *idleImages = [NSMutableArray array];
        
        for (NSUInteger i = 1; i<=6; i++) {
            UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"%zd", i+1]];
              [idleImages addObject:image];
        }
        self.userInteractionEnabled = NO;
        self.backgroundColor = [UIColor clearColor];
        self.layer.masksToBounds = YES;
        [self setHidden:YES];

    
        UIView *background = [[UIView alloc] initWithFrame:self.bounds];
        background.backgroundColor = [UIColor blackColor];
        background.alpha = 0.5;
        background.tag = 3458;
        background.autoresizesSubviews = YES;
        background.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleTopMargin;
        [self addSubview:background];

        UIView *whiteView=[UIView new];
        whiteView.layer.cornerRadius=5;
        whiteView.layer.masksToBounds=YES;
        whiteView.backgroundColor=[UIColor whiteColor];
        whiteView.frame=CGRectMake(newwidth/2-50, newheight/2-50,100, 100);
        whiteView.alpha=1;
        
        [self addSubview:whiteView];
        
        
        
        
        UIImageView *imageView=[UIImageView new];
//        imageView.backgroundColor=[UIColor whiteColor];

        imageView.frame=CGRectMake(0, 0, 64, 75);
          imageView.center=background.center;

        [self addSubview:imageView];
        [imageView bringSubviewToFront:self];
        
        
        //1.准备好数据源数组
        
        //2.指定数组给控件  animationImages:The array must contain UIImages. Setting hides the single image. default is nil
        imageView.animationImages=idleImages;
        //3.设置动画的时间
        [imageView setAnimationDuration:idleImages.count*0.05];
        //4.设置动画的播放次数
        imageView.animationRepeatCount=MAXFLOAT;
        //5.让其进行动画展示
        [imageView startAnimating];

    }
    return self;
}

- (void)setTitleString:(NSString*)title
{
    UILabel* lbl = (UILabel*)[self viewWithTag:1818];
    CGRect tempRect = lbl.frame;
    if(title.length >= 10){
        tempRect.size.height = 41;
        [lbl setFrame:tempRect];
        [lbl setNumberOfLines:2];
    }else{
        tempRect.size.height = 21;
        [lbl setFrame:tempRect];
        [lbl setNumberOfLines:1];
    }
    lbl.text = title;
}

- (void)setHidden:(BOOL)hidden {
//    [DMNetRequestErrorAlert setShareResultWith:hidden];
    [super setHidden:hidden];
}

@end

